package cn.js.sip.rat.system.controller;

import cn.js.sip.rat.system.entity.DicTypeEntity;
import cn.js.sip.rat.system.page.TableDataInfo;
import cn.js.sip.rat.system.service.DicTypeService;
import cn.js.sip.rat.system.util.ServletUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: cn.js.sip.rat.system.controller
 * @Description: TODO
 * @author: xuxiaoli
 * @Date: 2020-01-03   20:59
 */
@Api("用户管理")
@Controller
@RequestMapping("system/dic/type")
public class DicTypeController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(DicTypeController.class);
    private String prefix = "system/dic/type";

    @Resource(name = "dicTypeService")
    private DicTypeService dicTypeService;

    @ApiOperation("view")
    @RequiresPermissions("system:dic:view")
    @GetMapping
    public String menu() {
        return prefix + "/type";
    }

    @ApiOperation("list")
    @RequiresPermissions("system:dic:list")
    @PostMapping("list")
    @ResponseBody
    public TableDataInfo list(DicTypeEntity entity) {
        return dicTypeService.query(entity);
    }

    /**
     * 查询字典详细
     */
    @RequiresPermissions("system:dict:list")
    @GetMapping("/detail/{dictId}")
    public String detail(@PathVariable("dictId") String dictId, ModelMap mmap, HttpServletRequest request) {
        String pageNum = request.getParameter("pageSize");
        Integer pageNums = ServletUtils.getParameterToInt("pageSize");
        mmap.put("dict", dicTypeService.selectDictTypeById(dictId));
        mmap.put("dictList", dicTypeService.selectDictTypeAll());
        return "system/dic/data/data";
    }

}
